﻿@model Dyd.BaseService.ServiceCenter.Web.Models.ApiDoc
@{
    ViewBag.Title = "ApiDoc";
    var menuList = ViewBag.MenuList as IList<Dyd.BaseService.ServiceCenter.Domain.Model.tb_service>;
    var id = Convert.ToInt32(ViewBag.id);
    var key = ViewBag.key.ToString();
}

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>OpenAPI</title>

    <link href="~/Content/openapi.css" rel="stylesheet" />
    <style>
    </style>
    <script src="~/Scripts/jquery-1.8.2.min.js"></script>
    <script>

        $(function () {
            $("#search").on("click", function () {
                var key = $("#key").val();
                window.location.href = "/Service/ApiDoc?key=" + key;
            });

            $("#clearSearch").on("click", function () {
                var key = $("#key").val();
                window.location.href = "/Service/ApiDoc?serviceid=" + @id;
            });

        });
    </script>
</head>
<body>
    <div class="header">
        <div style="float:left; padding-left:10px;"><span style="color:white; font-size:25px; font-weight:bold;">点呀点服务中心ApiDoc</span></div>
        <div class="search"><input type="text" value="@ViewBag.Key" id="key"><input id="search" type="button" value="搜索" class="ml10 sbtn"></div>
    </div>
    <div class="content">

        <div class="fl w250 p10">
            <ul>
                @if (!string.IsNullOrWhiteSpace(key))
                {
                    <li><input id="clearSearch" type="button" class="btn1" value="清理搜索结果" /></li>
                }
                @foreach (var item in menuList)
                {
                    <li>
                        <a data-id="@item.id" class="@(id==item.id?"current":"")" href="/Service/ApiDoc?serviceid=@item.id&key=@ViewBag.key" title="服务">
                            <span>@Html.Raw(item.servicename)</span>
                        </a>
                    </li>
                }
            </ul>
        </div>
        <div class="fl p10">
            @foreach (var item in Model.ServiceDocList)
            {
                <h2>服务名称：<a href="/Service/ApiDoc?serviceid=@item.ServiceId" target="_blank">@Html.Raw(item.ServiceName)</a></h2>
                <div class="head">服务命名空间： @Html.Raw(item.ServiceNamespace)</div>
                foreach (var serviceProtocal in item.ServiceProtocalList)
                {
                    <div class="border1 mt20">
                        <div class="border">
                            <div class="head">描述：@Html.Raw(serviceProtocal.ServiceDoc.Text) </div>
                            <div class="head">详细描述：@Html.Raw(serviceProtocal.ServiceDoc.Description) </div>

                            @foreach (var method in serviceProtocal.MethodProtocols)
                            {
                            <div class="h20"></div>
                            <h5>方法名称：@Html.Raw(method.Name)</h5>
                            <p>
                                <div>
                                    作者：@Html.Raw(method.MethodDoc.Author)
                                </div>
                                <div>
                                    详细描述：@Html.Raw(method.MethodDoc.Description)
                                </div>
                                <div>
                                    描述：@Html.Raw(method.MethodDoc.Text)
                                </div>
                                <div>备注：@Html.Raw(method.MethodDoc.Note)</div>
                            </p>

                            <h5>参数</h5>
                            <table class="t">
                                <tr>
                                    <th>
                                        参数名
                                    </th>
                                    <th>
                                        参数类型名
                                    </th>
                                    <th>
                                        是否是自定义类型
                                    </th>
                                    <th>
                                        描述
                                    </th>
                                </tr>

                                @foreach (var para in method.InputParams)
                                    {
                                    <tr>
                                        <td>
                                            @Html.Raw(para.Name)
                                        </td>
                                        <td>
                                            @if (para.IsCustomType)
                                                {
                                                <a href="#@para.TypeName">@Html.Raw(para.TypeName)</a>
                                                }
                                                else
                                                {
                                                @Html.Raw(para.TypeName)
                                                }
                                        </td>
                                        <td>
                                            @Html.Raw(para.IsCustomType)
                                        </td>
                                        <td>
                                            @if (method.MethodDoc.InputParamsText.ContainsKey(para.Name))
                                                {
                                                @Html.Raw(method.MethodDoc.InputParamsText[para.Name])
                                                }
                                        </td>
                                    </tr>
                                    }
                            </table>

                            <h5>返回参数</h5>

                            <table class="t">
                                <tr>
                                    <th>
                                        参数名
                                    </th>
                                    <th>
                                        参数类型名
                                    </th>
                                    <th>
                                        是否是自定义类型
                                    </th>
                                    <th>
                                        返回参数描述
                                    </th>
                                </tr>
                                <tr>
                                    <td>
                                        @method.ReturnParam.Name
                                    </td>
                                    <td>
                                        @if (method.ReturnParam.IsCustomType)
                                            {
                                            <a href="#@method.ReturnParam.TypeName">@(method.ReturnParam.TypeName)</a>
                                            }
                                            else
                                            {
                                            @Html.Raw(method.ReturnParam.TypeName)
                                            }
                                    </td>

                                    <td>
                                        @method.ReturnParam.IsCustomType
                                    </td>
                                    <td>
                                        @Html.Raw(method.MethodDoc.ReturnParamText)
                                    </td>
                                </tr>
                            </table>

                            }

                        </div>

                        <h3>实体参数</h3>
                        @foreach (var entity in serviceProtocal.EntityProtocals)
                        {
                            <div class="border">
                                <div class="row"> <a name="@Html.Raw(entity.Name)">实体类名：@Html.Raw(entity.Name)</a> </div>
                                <div class="row">描述：@entity.EntityDoc.Text </div>
                                <div class="row">详细描述：@entity.EntityDoc.Description </div>
                                <div class="mt20"></div>

                                <table class="t">
                                    <tr>
                                        <th>
                                            属性名
                                        </th>
                                        <th>
                                            属性类型名
                                        </th>
                                        <th>
                                            描述
                                        </th>
                                        <th>
                                            详细描述
                                        </th>
                                    </tr>

                                    @for (int i = 0; i < entity.PropertyParams.Count(); i++)
                                    {
                                        <tr>
                                            <td>
                                                @Html.Raw(entity.PropertyParams[i].Name)
                                            </td>
                                            <td>
                                                @Html.Raw(entity.PropertyParams[i].TypeName)
                                            </td>
                                            <td>
                                                @Html.Raw(entity.PropertyDocs[i].Text)
                                            </td>
                                            <td>
                                                @Html.Raw(entity.PropertyDocs[i].Description)
                                            </td>
                                        </tr>
                                    }
                                </table>
                            </div>
                            <div class="mt20"></div>
                        }
                    </div>
                }
            }
        </div>
    </div>
</body>
</html>